package org.net.cms.controller.admin.student;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.net.cms.config.Result;
import org.net.cms.controller.admin.student.vo.StudentReqVO;
import org.net.cms.service.student.StudentService;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/student")
@Tag(name = "管理后台 - 学生")
public class StudentController {
    // 接口测试无误

    @Resource
    private StudentService studentService;

    @PostMapping("/update")
    @Operation(summary = "修改学生信息")
    public Result updateStudent(@RequestBody StudentReqVO studentReqVO) {
        studentService.update(studentReqVO);
        return Result.success();
    }

    @PostMapping("/delete")
    @Operation(summary = "删除学生信息")
    public Result delete(int id) {
        studentService.delete(id);
        return Result.success();
    }

    @GetMapping("/get")
    @Operation(summary = "获取学生详情信息")
    public Result getStudent(int id) {
        return Result.success(studentService.findById(id));
    }

    @GetMapping("/list")
    @Operation(summary = "获取学生列表")
    public Result studentList() {
        return Result.success(studentService.findAll());
    }

    @GetMapping("/my")
    @Operation(summary = "获取当前家长的孩子信息列表")
    public Result findMyStudents(int id) {
        return Result.success(studentService.findMyStudents(id));
    }

}
